package net.minecraft.src;

public class TileEntityVillageChest extends TileEntityChest {
	
	public World worldObj;
	
	protected TileEntityVillageChest() {
		super();
		worldObj = ModLoader.getMinecraftInstance().theWorld;
	}
	
    public void checkForAdjacentChests()
    {
        if (adjacentChestChecked)
        {
            return;
        }
        adjacentChestChecked = true;
        adjacentChestZNeg = null;
        adjacentChestXPos = null;
        adjacentChestXNeg = null;
        adjacentChestZPos = null;
        if (worldObj.getBlockId(xCoord - 1, yCoord, zCoord) == mod_TehMod.VillageChest.blockID)
        {
            adjacentChestXNeg = (TileEntityChest)worldObj.getBlockTileEntity(xCoord - 1, yCoord, zCoord);
        }
        if (worldObj.getBlockId(xCoord + 1, yCoord, zCoord) == mod_TehMod.VillageChest.blockID)
        {
            adjacentChestXPos = (TileEntityChest)worldObj.getBlockTileEntity(xCoord + 1, yCoord, zCoord);
        }
        if (worldObj.getBlockId(xCoord, yCoord, zCoord - 1) == mod_TehMod.VillageChest.blockID)
        {
            adjacentChestZNeg = (TileEntityChest)worldObj.getBlockTileEntity(xCoord, yCoord, zCoord - 1);
        }
        if (worldObj.getBlockId(xCoord, yCoord, zCoord + 1) == mod_TehMod.VillageChest.blockID)
        {
            adjacentChestZPos = (TileEntityChest)worldObj.getBlockTileEntity(xCoord, yCoord, zCoord + 1);
        }
        if (adjacentChestZNeg != null)
        {
            adjacentChestZNeg.updateContainingBlockInfo();
        }
        if (adjacentChestZPos != null)
        {
            adjacentChestZPos.updateContainingBlockInfo();
        }
        if (adjacentChestXPos != null)
        {
            adjacentChestXPos.updateContainingBlockInfo();
        }
        if (adjacentChestXNeg != null)
        {
            adjacentChestXNeg.updateContainingBlockInfo();
        }
    }
    
    public Block getBlockType() {
    	return mod_TehMod.VillageChest;
    }
    
    @Override
    public int getBlockMetadata() {
    	try {
    		return super.getBlockMetadata();
    	} catch (NullPointerException ex) {
    		return 0;
    	}
    }

}
